package com.my.ext.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.my.ext.service.IGroupService;
import com.my.ext.service.IMapService;
import com.my.ext.service.impl.MapService;
import com.my.ext.utils.AESCoder;
import com.my.ext.utils.ResultObject;

@RestController
@RequestMapping(value = "/api/map", method = {RequestMethod.POST, RequestMethod.GET})
public class MapController {

	@Autowired
	IMapService service;
	
	@Autowired
	IGroupService groupService;
	
	@RequestMapping("/queryMy")
	public ResultObject queryMyMap(String openid) {
		return service.queryMyMap(openid);
	}
	
	@RequestMapping("/go")
	public ResultObject go(int org, int groupid, String openid, int userid, int contr) {
		return service.go(org, groupid, openid, userid, contr);
	}
	
	@RequestMapping("/getStep")
	public ResultObject getStep(String openid, String iv, String data) {
		System.out.println(iv);
		System.out.println(data);
		return service.decode(data, iv, openid);
	}
	
	@RequestMapping("/answers")
	public ResultObject answers(String openid, int groupid) {
		groupService.modify(groupid, openid);
		ResultObject obj = new ResultObject();
		obj.setStatus(1);
		obj.setInfo("成功");
		return obj;
	}
	
}
